package com.funo.main.entities;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "U_MODULE")
public class Module implements Serializable {

	private static final long serialVersionUID = 3141331226167141167L;

	public static final String IS_LEAF_YES = "Y";
	public static final String IS_LEAF_NO = "N";

	// 主键Id
	@Id
	@Column(name = "MODULE_ID")
	private String id;

	// 上级模块
	@ManyToOne
	@JoinColumn(name = "PARENT_MODULE_ID")
	private Module parentModule;

	// 排列序号
	@Column(name = "ORDER_NUM")
	private Integer orderNum;

	// 模块名称
	@Column(name = "TEXT")
	private String text;

	// 功能概要
	@Column(name = "COMMENTS")
	private String comments;

	// 访问URL
	@Column(name = "COMPONENT")
	private String component;

	// 小图标URL
	@Column(name = "ICON_CLS")
	private String iconCls;

	//是否为叶子节点
	@Column(name = "IS_LEAF")
	private String isLeaf;

	@Transient
	private boolean leaf = true;

	@Transient
	private List<Module> children;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Module getParentModule() {
		return parentModule;
	}

	public void setParentModule(Module parentModule) {
		this.parentModule = parentModule;
	}

	public Integer getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(Integer orderNum) {
		this.orderNum = orderNum;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public String getIconCls() {
		return iconCls;
	}

	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getIsLeaf() {
		return isLeaf;
	}

	public void setIsLeaf(String isLeaf) {
		this.isLeaf = isLeaf;
		// if(IS_LEAF_YES.equals(isLeaf))this.leaf = true;
		// if(IS_LEAF_NO.equals(isLeaf))this.leaf = false;
	}

	public boolean getLeaf() {
		return leaf;
	}

	public void setLeaf(boolean leaf) {
		this.leaf = leaf;
	}

	public String getComponent() {
		return component;
	}

	public void setComponent(String component) {
		this.component = component;
	}

	public List<Module> getChildren() {
		return children;
	}

	public void setChildren(List<Module> children) {
		this.children = children;
	}

	public void addChildren(Module module) {
		this.children.add(module);
	}

}
